﻿/**
 * Created by Administrator
 */
var apiUrl = "http://bxh0736.vicp.cc:28499/wenxinservice/Home";
var user={
    account:'FSH20180514',
    key:'kingdee',
    // typecode:'hc'
};
var errorTimer = null;


// 根据宽度改变字体大小
(function(){
    var html = document.getElementsByTagName('html')[0];
    var fontSize = window.screen.width / 7.5 > 100 ? 100 : window.screen.width / 7.5;
    html.style.fontSize = fontSize + 'px';

    window.addEventListener('resize',function(){
        html.style.fontSize = fontSize + 'px';
    },false)
})();


function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
};

function setCookie(cookiename, cookievalue, hours) {
    var date = new Date();
    date.setTime(date.getTime() + Number(hours) * 3600 * 1000);
    document.cookie = cookiename + "=" + cookievalue + "; path=/;expires = " + date.toGMTString();

}

function getCookie(n){
    var name = n + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i<ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
    }
    return "";
}

function show_error_tip(options) {
    clearTimeout(errorTimer);
    
    var defaults={
        time:3000,
        str:'您的操作有误！',
        fontSize:'.16rem',
        useCapture:true
    };
    var opts = $.extend({},defaults,options);
    var oDiv="<div class='errorTip'>\n\
                <span class='text-c' style='font-size:"+opts.fontSize+"'>"+ opts.str+"</span>\n\
            </div>";
    $('.errorTip').length == 0 &&　$(oDiv).appendTo('body');
    var document_w=$(document).width();
    var max_w=$('.viewport').width();
    var obj_h=$('.errorTip').height();
    var obj_w=$('.errorTip').width();
    var m_left=(document_w-max_w)/2+(max_w-obj_w)/2;
    
    $('.errorTip').css({left:m_left+'px',marginTop:-obj_h/2+'px'});
    
    errorTimer =setTimeout(objRemove,opts.time);
    function objRemove(){
        $('.errorTip').remove();
    }
    
    $('body,html').on('click',function(event){
        event = event || window.event;
        event.stopPropagation();
        objRemove();
    });
    /*document.getElementsByTagName('body')[0].addEventListener('touch',function(){
        console.log(1);
        objRemove();
    },opts.useCapture);*/
}
